/**
 * 南向设备 api 封装
 *
 * @Author:    hzw
 * @Date:      2024-08-04 15:31:22
 * @Copyright  xnr
 */
import { postRequest, getRequest, postDownload } from '/@/lib/axios';
import { getMetricsMoack, getSystemInfoMoack } from "/@/api/mock/index.js"

const baseUrl = "/iotSystem"

export const iotApi = {

  /**
   * 应用许可证文件  @author  hzw
   */
  haspUpdate: (param) => {
    return postRequest(baseUrl + '/haspUpdate', param);
  },

  /**
   * 获取指纹信息  @author  hzw
   */
  haspGetInfo: (param) => {
    return postDownload(baseUrl + '/haspGetInfo', param);
  },

  /**
   * 请求许可证信息
   */
  fetchPermitData: (param) => {
    return postRequest(baseUrl + '/fetchPermitData', param);
  },

  /**
   * 基础信息  @author  hzw
   */
  getMetrics: (param) => {
    // return getRequest(baseUrl + '/getMetrics', param);
    return new Promise((r) => {
      r(getMetricsMoack)
    })
  },

  /**
   * 系统信息  @author  hzw
   */
  getSystemInfo: (param) => {
    // return getRequest(baseUrl + '/getSystemInfo', param);
    return new Promise((r) => {
      r(getSystemInfoMoack)
    })
  },

  /**
   * List查询（oss的模板） @author cyz
   */
  queryTemplateList: (param) => {
    return postRequest(baseUrl + '/queryTemplateList', param);
  },

  /**
   * 下载安装模板从 oss
   */
  downloadTemplate: (param) => {
    return postRequest(baseUrl + "/download", null, param);
  },

  /**
   * 上传模板到 oss
   */
  uploadTemplate: (param) => {
    return postRequest(baseUrl + "/upload", null, param);
  },

  /**
   * 获取任务
   */
  getTaskStatus: (taskId) => {
    return getRequest(`/iotSystem/${taskId}`);
  },

  /**
   * 系统设置 get
   */
  getIotConfig: () => {
    return getRequest(baseUrl + "/getIotConfig");
  },

  /**
  * 系统设置
  */
  setIotConfig: (param) => {
    return postRequest(baseUrl + "/setIotConfig", param);
  },

  /**
   * 分页查询  @author  hzw
   */
  queryPage: (param) => {
    return postRequest(baseUrl + '/queryPage', param);
  },

  queryList: (param) => {
    return postRequest(baseUrl + '/queryList', param);
  },

  /**
   * 增加  @author  hzw
   */
  add: (param) => {
    return postRequest(baseUrl + '/add', param);
  },

  /**
   * 修改  @author  hzw
   */
  update: (param) => {
    return postRequest(baseUrl + '/update', param);
  },
};
